<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 李邦琦 <1536549251@qq.com>
// +----------------------------------------------------------------------

namespace app\crm\controller;
use think\Loader;
use think\Cache;

class Visit extends CrmController
{
    /**
     * 渲染模板visitResult
     */
    public function visitResult()
    {
        $menuname = "Visit Result";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('visitResult');
    }


    /**
     * 渲染模板visitType
     */
    public function visitType()
    {
        $menuname = "Visit Type";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('visitType');
    }


    /**
     * 渲染模板addVisitResult
     */
    public function addVisitResult()
    {
        $menuname = "Visit Result";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('addVisitResult');
    }


    /**
     * 渲染模板addVisitType
     */
    public function addVisitType()
    {
        $menuname = "Visit Type";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('addVisitType');
    }


    /**
     * 渲染模板editVisitResult
     */
    public function editVisitResult()
    {
        $menuname = "Visit Result";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        $id = $_GET['id'];
        $table = 'vip_visit_result';
        $data = Loader::model('Visit')->getVisitSelect($table, $id);
        $this->assign('data', $data);
        // 模板输出
        return $this->fetch('editVisitResult');
    }


    /**
     * 渲染模板editVisitType
     */
    public function editVisitType()
    {
        $menuname = "Visit Type";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        $id = $_GET['id'];
        $table = 'vip_visit_type';
        $data = Loader::model('Visit')->getVisitSelect($table, $id);
        $this->assign('data', $data);
        // 模板输出
        return $this->fetch('editVisitType');
    }


    /**
     * 回访结果列表
     * @return json 回访结果数据
     */
    public function visitResultData ()
    {
        $page = $_REQUEST["page"];
        $limit = $_REQUEST["limit"];
        $arrData = Loader::model('Visit')->visitResultData($page,$limit);
        echo json_encode($arrData);
    }


    /**
     * 回访类型列表
     * @return json 回访类型数据
     */
    public function visitTypeData ()
    {
        $page = $_REQUEST["page"];
        $limit = $_REQUEST["limit"];
        $arrData = Loader::model('Visit')->visitTypeData($page,$limit);
        echo json_encode($arrData);
    }


    /**
     * 删除回访结果
     */
    public function delVisitResult ()
    {
        $id = $_REQUEST['id'];
        $table = 'vip_visit_result';
        Loader::model('Visit')->delVisitSelect($table, $id);
    }


    /**
     * 删除回访类型
     */
    public function delVisitType ()
    {
        $id = $_REQUEST['id'];
        $table = 'vip_visit_type';
        Loader::model('Visit')->delVisitSelect($table, $id);
    }


    /**
     * 新增回访结果
     */
    public function insertVisitResult ()
    {
        $data = $_REQUEST;
        $table = 'vip_visit_result';
        Loader::model('Visit')->addVisitSelect($table, $data);
    }


    /**
     * 新增回访类型
     */
    public function insertVisitType ()
    {
        $data = $_REQUEST;
        $table = 'vip_visit_type';
        Loader::model('Visit')->addVisitSelect($table, $data);
    }


    /**
     * 编辑回访结果
     */
    public function updateVisitResult ()
    {
        $data = $_REQUEST;
        $table = 'vip_visit_result';
        Loader::model('Visit')->updateVisitSelect($table, $data);
    }


    /**
     * 编辑回访类型
     */
    public function updateVisitType ()
    {
        $data = $_REQUEST;
        $table = 'vip_visit_type';
        Loader::model('Visit')->updateVisitSelect($table, $data);
    }

}